package com.kay;

import com.kay.component.DemoComponent;
import com.kay.config.ConsumerConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.*;

import java.io.IOException;
import java.util.concurrent.*;

/**
 * @Description:
 * @Author: Kay
 * @CreateDate: 2021/9/15$ 12:34$
 * @UpdateUser: Kay
 * @UpdateDate: 2021/9/15$ 12:34$
 */
public class ConsumerApplication {
    private static Logger logger = LoggerFactory.getLogger(ConsumerApplication.class);

    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        applicationContext.start();
        DemoComponent service = applicationContext.getBean(DemoComponent.class);
        logger.info("======================= 开始 ==================================");

        final ExecutorService executorService = Executors.newFixedThreadPool(12);

        // 线程池调用服务
        while (true){
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    service.methodA();
                    service.methodB();
                    service.methodC();
                }
            });
            Thread.sleep(20);
        }
    }
}
